package com.neusoft.elmboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neusoft.elmboot.Dto.BussinessDto;
import com.neusoft.elmboot.Vo.BussinessVo;
import com.neusoft.elmboot.mapper.BusinessMapper;
import com.neusoft.elmboot.po.BusinessEntity;
import com.neusoft.elmboot.service.BusinessService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, BusinessEntity> implements BusinessService{

    @Override
    public List<BussinessVo> getBussinessVoList() {
        List<BusinessEntity> businessEntityList = this.list();
        List<BussinessVo> bussinessVoList = businessEntityList.stream().map((item) -> {
            BussinessVo bussinessVo = new BussinessVo();
            BeanUtils.copyProperties(item, bussinessVo);
            return bussinessVo;
        }).collect(Collectors.toList());
        return bussinessVoList;


    }

    @Override
    public void add(BussinessDto bussinessDto) {
        BusinessEntity businessEntity = new BusinessEntity();
        BeanUtils.copyProperties(bussinessDto, businessEntity);
        this.save(businessEntity);




    }
}
